home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / VideoFolder 1.0a / Source / MoreFiles 1.4.1 / DirectoryCopy.h < prev    next >
Text File  |  1995-12-21  |  7KB  |  178 lines

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    DirectoryCopy: A robust, general purpose directory copy routine.
  5. **
  6. **    by Jim Luther, Apple Developer Technical Support Emeritus
  7. **
  8. **    File:        DirectoryCopy.h
  9. **
  10. **    Copyright © 1992-1995 Apple Computer, Inc.
  11. **    All rights reserved.
  12. **
  13. **    You may incorporate this sample code into your applications without
  14. **    restriction, though the sample code has been provided "AS IS" and the
  15. **    responsibility for its operation is 100% yours.  However, what you are
  16. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  17. **    after having made changes. If you're going to re-distribute the source,
  18. **    we require that you make it clear in the source that the code was
  19. **    descended from Apple Sample Code, but that you've made changes.
  20. */
  21.  
  22. #ifndef __DIRECTORYCOPY__
  23. #define __DIRECTORYCOPY__
  24.  
  25. #include <Types.h>
  26. #include <Files.h>
  27.  
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31.  
  32. /*****************************************************************************/
  33.  
  34. enum
  35. {
  36.     getNextItemOp            = 1,    /* couldn't access items in this directory - no access privileges */
  37.     copyDirCommentOp        = 2,    /* couldn't copy directory's Finder comment */
  38.     copyDirAccessPrivsOp    = 3,    /* couldn't copy directory's AFP access privileges */
  39.     copyDirFMAttributesOp    = 4,    /* couldn't copy directory's File Manager attributes */
  40.     dirCreateOp                = 5,    /* couldn't create destination directory */
  41.     fileCopyOp                = 6        /* couldn't copy file */
  42. };
  43.  
  44. /*****************************************************************************/
  45.  
  46. typedef    pascal    Boolean    (*CopyErrProcPtr) (OSErr error,
  47.                                            short failedOperation,
  48.                                            short srcVRefNum,
  49.                                            long srcDirID,
  50.                                            StringPtr srcName,
  51.                                            short dstVRefNum,
  52.                                            long dstDirID,
  53.                                            StringPtr dstName);
  54. /*    ¶ Prototype for the CopyErrProc function DirectoryCopy calls.
  55.     This is the prototype for the CopyErrProc function DirectoryCopy
  56.     calls if an error condition is detected sometime during the copy.  If
  57.     CopyErrProc returns true, then DirectoryCopy attempts to continue with
  58.     the directory copy operation.  If CopyErrProc returns false, then
  59.     DirectoryCopy stops the directory copy operation.
  60.  
  61.     error            input:    The error result code that caused CopyErrProc to
  62.                             be called.
  63.     failedOperation    input:    The operation that returned an error to
  64.                             DirectoryCopy.
  65.     srcVRefNum        input:    Source volume specification.
  66.     srcDirID        input:    Source directory ID.
  67.     srcName            input:    Source file or directory name, or nil if
  68.                             srcDirID specifies the directory.
  69.     dstVRefNum        input:    Destination volume specification.
  70.     dstDirID        input:    Destination directory ID.
  71.     dstName            input:    Destination file or directory name, or nil if
  72.                             dstDirID specifies the directory.
  73.  
  74.     __________
  75.     
  76.     Also see:    DirectoryCopy, FSpDirectoryCopy
  77. */
  78.  
  79. #define CallCopyErrProc(userRoutine, error, failedOperation, srcVRefNum, srcDirID, srcName, dstVRefNum, dstDirID, dstName) \
  80.         (*(userRoutine))((error), (failedOperation), (srcVRefNum), (srcDirID), (srcName), (dstVRefNum), (dstDirID), (dstName))
  81.  
  82. /*****************************************************************************/
  83.  
  84. pascal    OSErr    DirectoryCopy(short srcVRefNum,
  85.                               long srcDirID,
  86.                               StringPtr srcName,
  87.                               short dstVRefNum,
  88.                               long dstDirID,
  89.                               StringPtr dstName,
  90.                               void *copyBufferPtr,
  91.                               long copyBufferSize,
  92.                               Boolean preflight,
  93.                               CopyErrProcPtr copyErrHandler);
  94. /*    ¶ Make a copy of a directory structure in a new location.
  95.     The DirectoryCopy function makes a copy of a directory structure in a
  96.     new location. If copyBufferPtr <> NIL, it points to a buffer of
  97.     copyBufferSize that is used to copy files data.  The larger the
  98.     supplied buffer, the faster the copy.  If copyBufferPtr = NIL, then this
  99.     routine allocates a buffer in the application heap. If you pass a
  100.     copy buffer to this routine, make its size a multiple of 512
  101.     ($200) bytes for optimum performance.
  102.     
  103.     srcVRefNum        input:    Source volume specification.
  104.     srcDirID        input:    Source directory ID.
  105.     srcName            input:    Source directory name, or nil if
  106.                             srcDirID specifies the directory.
  107.     dstVRefNum        input:    Destination volume specification.
  108.     dstDirID        input:    Destination directory ID.
  109.     dstName            input:    Destination directory name, or nil if
  110.                             dstDirID specifies the directory.
  111.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  112.                             is used the i/o buffer for the copy or
  113.                             nil if you want DirectoryCopy to allocate its
  114.                             own buffer in the application heap.
  115.     copyBufferSize    input:    The size of the buffer pointed to
  116.                             by copyBufferPtr.
  117.     preflight        input:    If true, DirectoryCopy makes sure there are
  118.                             enough allocation blocks on the destination
  119.                             volume to hold the directory's files before
  120.                             starting the copy.
  121.     copyErrHandler    input:    A pointer to the routine you want called if an
  122.                             error condition is detected during the copy, or
  123.                             nil if you don't want to handle error conditions.
  124.                             Error handling is recommended...
  125.  
  126.     __________
  127.     
  128.     Also see:    CopyErrProcPtr, FSpDirectoryCopy, FileCopy, FSpFileCopy
  129. */
  130.  
  131. /*****************************************************************************/
  132.  
  133. pascal    OSErr    FSpDirectoryCopy(const FSSpec *srcSpec,
  134.                                  const FSSpec *dstSpec,
  135.                                  void *copyBufferPtr,
  136.                                  long copyBufferSize,
  137.                                  Boolean preflight,
  138.                                  CopyErrProcPtr copyErrHandler);
  139. /*    ¶ Make a copy of a directory structure in a new location.
  140.     The FSpDirectoryCopy function makes a copy of a directory structure in a
  141.     new location. If copyBufferPtr <> NIL, it points to a buffer of
  142.     copyBufferSize that is used to copy files data.  The larger the
  143.     supplied buffer, the faster the copy.  If copyBufferPtr = NIL, then this
  144.     routine allocates a buffer in the application heap. If you pass a
  145.     copy buffer to this routine, make its size a multiple of 512
  146.     ($200) bytes for optimum performance.
  147.     
  148.     srcSpec            input:    An FSSpec record specifying the directory to copy.
  149.     dstSpec            input:    An FSSpec record specifying destination directory
  150.                             of the copy.
  151.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  152.                             is used the i/o buffer for the copy or
  153.                             nil if you want DirectoryCopy to allocate its
  154.                             own buffer in the application heap.
  155.     copyBufferSize    input:    The size of the buffer pointed to
  156.                             by copyBufferPtr.
  157.     preflight        input:    If true, FSpDirectoryCopy makes sure there are
  158.                             enough allocation blocks on the destination
  159.                             volume to hold the directory's files before
  160.                             starting the copy.
  161.     copyErrHandler    input:    A pointer to the routine you want called if an
  162.                             error condition is detected during the copy, or
  163.                             nil if you don't want to handle error conditions.
  164.                             Error handling is recommended...
  165.  
  166.     __________
  167.     
  168.     Also see:    CopyErrProcPtr, DirectoryCopy
  169. */
  170.  
  171. /*****************************************************************************/
  172.  
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176.  
  177. #endif    /* __DIRECTORYCOPY__ */
  178.